<?php       
class dbConnection extends PDO{
     private $db;
     private $host=DB_HOST;
     private $username=DB_USER;
     private $password=DB_PASSWORD;
     private $database=DB_DATABASE;
     private $port=DB_PORT;
     
    public function __construct(){  
        if(!isset($this->db)) {
          try{
            $this->db = parent::__construct("mysql:host=".$this->host.";port=".$this->port.";dbname=".$this->database, $this->username, $this->password);
            parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);         
          }catch(PDOException $e){
            echo "Error creating DB connection". $e->getMessage();
          } 
        }
      }            
}      
                                 
 ?>
